//    Copyright (C) Kherty.  All rights reserved.
using System.Windows.Media;
using OpenLS.Drawing;

namespace OpenLS.Spreadsheet
{
    class ColorScaleInformation
    {
        private readonly SpreadsheetColor firstColor;
        private readonly SpreadsheetColor secondColor;
        private readonly double interpolationValue;

        public ColorScaleInformation(SpreadsheetColor firstColor, SpreadsheetColor secondColor, double interpolationValue)
        {
            this.firstColor = firstColor;
            this.secondColor = secondColor;
            this.interpolationValue = interpolationValue;
        }

        public Color GetColor (ColorScheme colorScheme)
        {
            var c1 = firstColor.GetColor(colorScheme);
            var c2 = secondColor.GetColor(colorScheme);
            var factor1 = (float) (1 - interpolationValue);
            var factor2 = (float) interpolationValue;
            return Color.FromScRgb(
                c1.ScA*(factor1) + c2.ScA*factor2,
                c1.ScR*(factor1) + c2.ScR*factor2,
                c1.ScG*(factor1) + c2.ScG*factor2,
                c1.ScB*(factor1) + c2.ScB*factor2
                );
        }
    }
}
